using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Acme.Northwind.Install
{
	/// <summary>
	/// 
	/// </summary>
	public partial class AzureCopyControl : UserControl
	{
		/// <summary>
		/// 
		/// </summary>
		public AzureCopyControl()
		{
			InitializeComponent();
		}

		/// <summary>
		/// 
		/// </summary>
		public void LoadSettings(InstallSettings settings)
		{
			txtDestDatabase.Text = settings.CloudDatabase;
			txtDestPassword.Text = settings.CloudPassword;
			txtDestServer.Text = settings.CloudServer;
			txtDestUserName.Text = settings.CloudUserName;
			txtSourceDatabase.Text = settings.PrimaryDatabase;
			txtSourcePassword.Text = settings.PrimaryPassword;
			txtSourceServer.Text = settings.PrimaryServer;
			txtSourceUserName.Text = settings.PrimaryUserName;
			optSourceIntegratedSecurity.Checked = settings.PrimaryUseIntegratedSecurity;
			optSourceUserPassword.Checked = !optSourceIntegratedSecurity.Checked;

			this.UpdateLogin();
		}

		private void optSourceIntegratedSecurity_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateLogin();
		}

		private void optSourceUserPassword_CheckedChanged(object sender, EventArgs e)
		{
			this.UpdateLogin();
		}

		private void UpdateLogin()
		{
			txtSourceUserName.Enabled = !optSourceIntegratedSecurity.Checked;
			txtSourcePassword.Enabled = !optSourceIntegratedSecurity.Checked;
		}

		/// <summary>
		/// 
		/// </summary>
		public void SaveSettings(InstallSettings settings)
		{
			settings.CloudDatabase = txtDestDatabase.Text;
			settings.CloudPassword = txtDestPassword.Text;
			settings.CloudServer = txtDestServer.Text;
			settings.CloudUserName = txtDestUserName.Text;
			settings.PrimaryDatabase = txtSourceDatabase.Text;
			settings.PrimaryPassword = txtSourcePassword.Text;
			settings.PrimaryServer = txtSourceServer.Text;
			settings.PrimaryUserName = txtSourceUserName.Text;
			settings.PrimaryUseIntegratedSecurity = optSourceIntegratedSecurity.Checked;
		}

	}

}
